home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d949.lha / BBBBS / BBBBS65.lha / rexx / ChangeUserName.rexx < prev    next >
OS/2 REXX Batch file  |  1993-10-22  |  4KB  |  173 lines

  1. /* $VER: ChangeUserName.rexx 6.5 (22.10.93)
  2.  * copyright 1991-93 Richard Lee Stockton
  3.  * FREELY DISTRIBUTABLE
  4. */
  5.  
  6. SIGNAL ON BREAK_C
  7. SIGNAL ON BREAK_E
  8. IF ADDRESS()='BAUD' THEN CR='0D'x
  9. ELSE CR=''
  10.  
  11. PARSE ARG OLD_NAME
  12. IF STRIP(OLD_NAME)='' THEN OLD_NAME=GETCLIP('BBS_oldname')
  13. IF STRIP(OLD_NAME)='' THEN
  14.   DO
  15.     SAY '  Usage:  rx  ChangeUserName  OLD_USER_NAME'
  16.     SAY 'Example:  rx  ChangeUserName  THE_MAD_HACKER'
  17.     CALL BYE(10)
  18.   END
  19. OLD_NAME=TRANSLATE(STRIP(UPPER(OLD_NAME)),'_',' ')
  20. OLD_NAME=COMPRESS(OLD_NAME,'.')
  21.  
  22. bbspath=GETCLIP('BBS_path')
  23. IF bbspath='' THEN
  24.   DO
  25.     figarg='s:CONFIG.BBS'
  26.     IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
  27.     x=OPEN(f,figarg,'R')
  28.     IF x=0 THEN
  29.       DO
  30.         SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
  31.         EXIT(20)
  32.       END
  33.     lynes.=''
  34.     DO i=1 TO 6
  35.       lynes.i=READLN(f)
  36.     END
  37.     CALL CLOSE(f)
  38.     bbspath=WORD(lynes.6,1)
  39.     IF bbspath='' | ~EXISTS(bbspath) THEN
  40.       DO
  41.         SAY 'The bbspath, 'bbspath', does not exist!'
  42.         CALL BYE(1);
  43.       END
  44.   END
  45.  
  46. /* load first line of userfile */
  47.  
  48. SAY OLD_NAME
  49. x=OPEN(f,bbspath'Users/'OLD_NAME,'R')
  50. IF x=0 THEN EXIT(2);
  51. fullname=READLN(f)
  52. CALL CLOSE(f);
  53.  
  54.  
  55. /* let operator enter new name */
  56.  
  57. SAY 'Full Name:' fullname||CR
  58. OPTIONS PROMPT 'User Name: '
  59. PULL NEW_NAME
  60. IF STRIP(NEW_NAME)='' THEN NEW_NAME=UPPER(fullname)
  61. NEW_NAME=TRANSLATE(STRIP(NEW_NAME),'_',' ')
  62. NEW_NAME=COMPRESS(NEW_NAME,'.')
  63. IF EXISTS(bbspath'Users/'NEW_NAME) THEN
  64.   DO
  65.     SAY NEW_NAME 'already exists!'CR
  66.     CALL BYE(3);
  67.   END
  68.  
  69. OPTIONS PROMPT 'Rename' OLD_NAME 'to' NEW_NAME '? (y/N) > '
  70. PULL temp
  71. IF UPPER(LEFT(temp,1))~='Y' THEN EXIT(0)
  72.  
  73.  
  74. /* rename */
  75.  
  76. SAY 'Renaming User files...'CR
  77. CALL RENAME(bbspath'Users/'OLD_NAME,bbspath'Users/'NEW_NAME)
  78. CALL RENAME(bbspath'Email/'OLD_NAME,bbspath'Email/'NEW_NAME)
  79. CALL RENAME(bbspath'EmailFiles/'OLD_NAME,bbspath'EmailFiles/'NEW_NAME)
  80.  
  81. OPTIONS PROMPT 'Re-Address Email FROM' OLD_NAME'? (y/N) > '
  82. PULL temp
  83. IF UPPER(LEFT(temp,1))='Y' THEN
  84.   DO
  85.     SAY 'Re-Addressing EMail...'CR
  86.     emailist=SHOWDIR(bbspath'Email','D')
  87.     DO i=1 TO WORDS(emailist)
  88.       user=WORD(emailist,i)
  89.       email=SHOWDIR(bbspath'Email/'user,'F')
  90.       DO j=1 TO WORDS(email)
  91.         mail=WORD(email,j)
  92.         IF POS(OLD_NAME,mail)>0 THEN
  93.           DO
  94.             x=OPEN(f,bbspath'EMail/'user'/'mail,'R')
  95.             IF x=0 THEN
  96.               DO
  97.                 SAY user'/'mail 'failed to open for reading!'CR
  98.                 ITERATE j
  99.               END
  100.             lynes.=''
  101.             DO k=1
  102.               line=READLN(f)
  103.               IF EOF(f) THEN LEAVE k
  104.               lynes.k=line
  105.             END
  106.             CALL CLOSE(f)
  107.             lynes.0=k-1
  108.             PARSE VAR lynes.2 ltemp junk rtemp
  109.             lynes.2=' 'ltemp NEW_NAME||rtemp
  110.             PARSE VAR mail junk'.'num
  111.             CALL DELETE(bbspath'EMail/'user'/'mail)
  112.             mail=NEW_NAME'.'num
  113.             x=OPEN(f,bbspath'EMail/'user'/'mail,'W')
  114.             IF x=0 THEN
  115.               DO
  116.                 SAY user'/'mail 'failed to open for writing!'CR
  117.                 ITERATE j
  118.               END
  119.             DO k=1 TO lynes.0
  120.               CALL WRITELN(f,lynes.k)
  121.             END
  122.             CALL CLOSE(f)
  123.           END
  124.       END
  125.     END
  126.   END
  127.  
  128. CALL DELETE(bbspath'Lists/Users')
  129. CALL SETCLIP('BBS_newname',NEW_NAME)
  130. IF GETCLIP('BBS_oldname')='' THEN
  131.   DO
  132.     IF SHOW('P','BBBBS') THEN CALL SETCLIP('BBS_localusers',1)
  133.     IF SHOW('P','BBBBS_LOCAL') THEN CALL SETCLIP('BBS_mainusers',1)
  134.   END
  135. ELSE CALL SETCLIP('BBS_oldname')
  136. IF ARG()>0 THEN SAY 'Done!'
  137. CALL BYE(0);
  138.  
  139.  
  140. BYE:
  141. ARG byearg
  142. EXIT(byearg);
  143.  
  144.  
  145. BREAK_C:
  146. BREAK_E:
  147. SAY '*** CTRL BREAK'CR
  148. EXIT(5);
  149.  
  150.  
  151.  
  152. /*********  THESE NEXT TWO ROUTINES NOT YET IMPLEMENTED!  *********/
  153.  
  154.  
  155. /* search filenotes for OLD_NAME and replace with NEW_NAME */
  156. do_filenotes:
  157. OPTIONS PROMPT 'Search filenotes and replace' OLD_NAME 'with' NEW_NAME '? '
  158. PULL temp
  159. IF UPPER(LEFT(temp,1))~='Y' THEN CALL BYE(1)
  160.   DO
  161.   END
  162. RETURN
  163.  
  164.  
  165. /* search message bases for OLD_NAME and replace with NEW_NAME */
  166. do_msgs:
  167. OPTIONS PROMPT 'Search message bases and replace' OLD_NAME 'with' NEW_NAME '? '
  168. PULL temp
  169. IF UPPER(LEFT(temp,1))~='Y' THEN CALl BYE(1);
  170. RETURN
  171.  
  172. /* ChangeUserName.rexx */
  173.